package ontology;

import java.util.List;
import java.util.ArrayList;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * This class is used to parse the 'fe' elements of the FrameNet ontology 
 * file (frXML/frames.xml). These elements have the following structure:
 * 
 * fe @name @coreType
 *   > semTypes
 *       > semType* @name
 *
 */

public class FrameElement {

	public String name;
	public String coreType;
	public List<String> semTypes = new ArrayList<String>();
	
	public FrameElement(Element e) {
		name = e.getAttribute("name");
		coreType = e.getAttribute("coreType");
		NodeList ns = e.getChildNodes();
		for (int i=0;i<ns.getLength();i++) {
			Node n = ns.item(i);
			String s = n.getNodeName();
			if (s.equals("semTypes")) {
				NodeList nns = ((Element) n).getChildNodes();
				for (int j=0;j<nns.getLength();j++) {
					Node nn = nns.item(j);
					String ss = nn.getNodeName();
					if (ss.equals("semType")) {
						semTypes.add(((Element) nn).getAttribute("name"));
					}
				}			
			}
		}		
	}
	
	
	
}
